home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-04-21 | 9.4 KB | 342 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: DrawProxy.cpp
- // Release Version: $ 1.0d1 $
- //
- // Author: Henri Lamiraux
- // Creation Date: 3/28/94
- //
- // Copyright: © 1993, 1994 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef DRAWPROXY_H
- #include "DrawProxy.h"
- #endif
-
- #ifndef DRAWPART_H
- #include "DrawPart.h"
- #endif
-
- #ifndef DRAWFRAME_H
- #include "DrawFrame.h"
- #endif
-
- #ifndef SHAPES_H
- #include "Shapes.h"
- #endif
-
- #ifndef DRAWPROXYBORDER_
- #include "DrawProxyBorder.h"
- #endif
-
- // ----- Framework Includes -----
-
- #ifndef FWUTIL_H
- #include "FWUtil.h"
- #endif
-
- #ifndef FWPART_H
- #include "FWPart.h"
- #endif
-
- #ifndef FWPARTING_H
- #include "FWParting.h"
- #endif
-
- #ifndef FWFACET_H
- #include <FWFacet.h>
- #endif
-
- #ifndef FWRECT_H
- #include "FWRect.h"
- #endif
-
- // ----- OPF Foundation Includes -----
-
- #ifndef BCOLL_H
- #include <BCColl.h>
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef _SHAPE_
- #include <Shape.h>
- #endif
-
- #ifndef _TRNSFORM_
- #include <Trnsform.h>
- #endif
-
- // ----- Macintosh Includes -----
-
- #ifndef mathRoutinesIncludes
- #include <math routines.h>
- #endif
-
- #pragma segment drawpart
-
- //=========================================================================
- // •• CDrawProxyRun
- //=========================================================================
-
- //------------------------------------------------------------------------------
- // • CDrawProxyRun::CDrawProxyRun
- //------------------------------------------------------------------------------
-
- CDrawProxyRun::CDrawProxyRun()
- {
- fShape = NULL;
- }
-
- //------------------------------------------------------------------------------
- // • CDrawProxyRun::InitDrawProxyRun
- //------------------------------------------------------------------------------
-
- void CDrawProxyRun::InitDrawProxyRun(CDrawPart* drawPart)
- {
- InitProxyRun(drawPart);
- fDrawPart = drawPart;
- }
-
- //------------------------------------------------------------------------------
- // • CDrawProxyRun::~CDrawProxyRun
- //------------------------------------------------------------------------------
-
- CDrawProxyRun::~CDrawProxyRun()
- {
- }
-
- //------------------------------------------------------------------------------
- // • CDrawProxyRun::GetFacetExternalTransform
- //------------------------------------------------------------------------------
-
- void CDrawProxyRun::GetFacetExternalTransform(XMPFrame* xmpFrame, XMPTransform* facetTransform)
- {
- FW_UNUSED(xmpFrame);
-
- FW_CRect box = fShape->GetBoundingBox();
- facetTransform->Reset();
- FW_CPoint offset(box.left, box.top);
- facetTransform->MoveBy(offset);
- }
-
- //------------------------------------------------------------------------------
- // • CDrawProxyRun::UsedShapeChanged
- //------------------------------------------------------------------------------
-
- void CDrawProxyRun::UsedShapeChanged(XMPFrame* xmpFrame)
- {
- if (fShape) // fShape might be null if UsedShapeChanged called early
- {
- // We assume here that all embedded facets have the same
- // externalTransform
-
- XMPFrameFacetIterator* ite = xmpFrame->CreateFacetIterator();
- XMPFacet *xmpFacet = ite->First();
- delete ite;
-
- if (xmpFacet)
- {
- XMPShape *shape = ::NewXMPShape(xmpFrame->GetFrameShape());
- shape->Transform(xmpFacet->GetExternalTransform());
- FW_CRect rect;
- shape->GetBoundingBox(&rect);
- delete shape;
- fShape->ProxyShapeChanged(rect);
- }
- }
-
- FW_CProxyRun::UsedShapeChanged(xmpFrame);
- }
-
- //------------------------------------------------------------------------------
- // • CDrawProxyRun::MoveBefore
- //------------------------------------------------------------------------------
-
- void CDrawProxyRun::MoveBefore(CDrawProxyRun* before)
- {
- FW_CPartFacetIterator ite(fDrawPart, fDrawPart->GetMainPresentation());
- FW_CFacet* facet;
- while (!ite.IsDone())
- {
- facet = ite.CurrentItem();
- XMPFacetIterator* ite2 = facet->GetXMPFacet()->CreateFacetIterator(kXMPChildrenOnly, kXMPFrontToBack);
- for (XMPFacet* xmpFacet = ite2->First(); ite2->IsNotComplete(); xmpFacet = ite2->Next())
- {
- if (xmpFacet->GetFrame()->GetPart() == GetXMPPart())
- {
- XMPFacetIterator* ite3 = facet->GetXMPFacet()->CreateFacetIterator(kXMPChildrenOnly, kXMPFrontToBack);
- for (XMPFacet* xmpFacet2 = ite3->First(); ite3->IsNotComplete(); xmpFacet2 = ite3->Next())
- {
- if (xmpFacet2->GetFrame()->GetPart() == before->GetXMPPart())
- {
- facet->GetXMPFacet()->MoveBefore(xmpFacet, xmpFacet2);
- break;
- }
- }
- delete ite3;
- }
- }
- delete ite2;
- ite.Next();
- }
- }
-
- //------------------------------------------------------------------------------
- // • CDrawProxyRun::MoveBehind
- //------------------------------------------------------------------------------
-
- void CDrawProxyRun::MoveBehind(CDrawProxyRun* behind)
- {
- FW_CPartFacetIterator ite(fDrawPart, fDrawPart->GetMainPresentation());
- FW_CFacet* facet;
- while (!ite.IsDone())
- {
- facet = ite.CurrentItem();
- XMPFacetIterator* ite2 = facet->GetXMPFacet()->CreateFacetIterator(kXMPChildrenOnly, kXMPFrontToBack);
- for (XMPFacet* xmpFacet = ite2->First(); ite2->IsNotComplete(); xmpFacet = ite2->Next())
- {
- if (xmpFacet->GetFrame()->GetPart() == GetXMPPart())
- {
- XMPFacetIterator* ite3 = facet->GetXMPFacet()->CreateFacetIterator(kXMPChildrenOnly, kXMPFrontToBack);
- for (XMPFacet* xmpFacet2 = ite3->First(); ite3->IsNotComplete(); xmpFacet2 = ite3->Next())
- {
- if (xmpFacet2->GetFrame()->GetPart() == behind->GetXMPPart())
- {
- facet->GetXMPFacet()->MoveBehind(xmpFacet, xmpFacet2);
- break;
- }
- }
- delete ite3;
- }
- }
- delete ite2;
- ite.Next();
- }
- }
-
- //------------------------------------------------------------------------------
- // • CDrawProxyRun::MoveFirst
- //------------------------------------------------------------------------------
-
- void CDrawProxyRun::MoveFirst()
- {
- FW_CPartFacetIterator ite(fDrawPart, fDrawPart->GetMainPresentation());
- FW_CFacet* facet;
- while (!ite.IsDone())
- {
- facet = ite.CurrentItem();
- XMPFacetIterator* ite2 = facet->GetXMPFacet()->CreateFacetIterator(kXMPChildrenOnly, kXMPBackToFront);
- for (XMPFacet* xmpFacet = ite2->First(); ite2->IsNotComplete(); xmpFacet = ite2->Next())
- {
- if (xmpFacet->GetFrame()->GetPart() == GetXMPPart())
- facet->GetXMPFacet()->MoveBefore(xmpFacet, NULL);
- }
- delete ite2;
- ite.Next();
- }
- }
-
- //------------------------------------------------------------------------------
- // • CDrawProxyRun::MoveLast
- //------------------------------------------------------------------------------
-
- void CDrawProxyRun::MoveLast()
- {
- FW_CPartFacetIterator ite(fDrawPart, fDrawPart->GetMainPresentation());
- FW_CFacet* facet;
- while (!ite.IsDone())
- {
- facet = ite.CurrentItem();
- XMPFacetIterator* ite2 = facet->GetXMPFacet()->CreateFacetIterator(kXMPChildrenOnly, kXMPFrontToBack);
- for (XMPFacet* xmpFacet = ite2->First(); ite2->IsNotComplete(); xmpFacet = ite2->Next())
- {
- if (xmpFacet->GetFrame()->GetPart() == GetXMPPart())
- facet->GetXMPFacet()->MoveBehind(xmpFacet, NULL);
- }
- delete ite2;
- ite.Next();
- }
- }
-
- //------------------------------------------------------------------------------
- // • CDrawProxyRun::NewProxyBorder
- //------------------------------------------------------------------------------
-
- FW_CBaseProxyBorder* CDrawProxyRun::NewProxyBorder()
- {
- CDrawProxyBorder* border = new CDrawProxyBorder;
- border->InitDrawProxyBorder(this);
- return border;
- }
-
- //------------------------------------------------------------------------------
- // • CDrawProxyRun::SetSelectState
- //------------------------------------------------------------------------------
-
- void CDrawProxyRun::SetSelectState(FW_Boolean state)
- {
- FW_CProxyRun::SetSelectState(state);
-
- // ----- Set the selected flag in facet -----
- BC_TCollectionActiveIterator<FW_CProxyFrame*> ite(*this->GetProxyFrameList());
- while (!ite.IsDone())
- {
- XMPFrameFacetIterator ite2((*ite.CurrentItem())->GetXMPFrame());
- for (XMPFacet* xmpFacet = ite2.First(); ite2.IsNotComplete(); xmpFacet = ite2.Next())
- xmpFacet->SetSelected(state);
- ite.Next();
- }
- }
-
- //------------------------------------------------------------------------------
- // • CDrawProxyRun::OffsetProxyFrames
- //------------------------------------------------------------------------------
-
- void CDrawProxyRun::OffsetProxyFrames(const FW_CPoint& offset)
- {
- BC_TCollectionActiveIterator<FW_CProxyFrame*> ite(*this->GetProxyFrameList());
- while (!ite.IsDone())
- {
- (*ite.CurrentItem())->OffsetFrame(offset);
- ite.Next();
- }
-
- GetProxyBorder()->BorderHasChanged(TRUE);
- }
-
- //------------------------------------------------------------------------------
- // • CDrawProxyRun::PlaceProxyFrames
- //------------------------------------------------------------------------------
-
- void CDrawProxyRun::PlaceProxyFrames(const FW_CPoint& position)
- {
- BC_TCollectionActiveIterator<FW_CProxyFrame*> ite(*this->GetProxyFrameList());
- while (!ite.IsDone())
- {
- (*ite.CurrentItem())->PlaceFrame(position);
- ite.Next();
- }
-
- GetProxyBorder()->BorderHasChanged(TRUE);
- }
-
- //------------------------------------------------------------------------------
- // • CDrawProxyRun::ResizeProxyFrames
- //------------------------------------------------------------------------------
-
- void CDrawProxyRun::ResizeProxyFrames(XMPShape* newShape)
- {
- BC_TCollectionActiveIterator<FW_CProxyFrame*> ite(*this->GetProxyFrameList());
- while (!ite.IsDone())
- {
- XMPShape *shape = ::NewXMPShape(newShape);
- (*ite.CurrentItem())->ResizeFrame(shape);
- ite.Next();
- }
- delete newShape;
- GetProxyBorder()->BorderHasChanged(TRUE);
- }
-
-